package pack.help.realRobot.uC;

import pack.help.RobotCommand;

public class Buffer {
	
	private RobotCommand current;
	private RobotCommand next;
	
	private int bufferedCmds = 0;
	
	public void shift(){
		if (bufferedCmds > 0) {
			current = new RobotCommand(next);
			next = null;
			bufferedCmds--;
		}
	}
	
	public void addCommand(RobotCommand cmd){
		if (bufferedCmds == 0){
			current = cmd;
		} else {
			next = cmd;
		}
		bufferedCmds++;
	}
	
	public int getBufferedCmds(){
		return this.bufferedCmds;
	}
	
	public RobotCommand getCurrent(){
		return current;
	}
	
	public RobotCommand getNext(){
		return next;
	}
	
	public void reset(){
		bufferedCmds = 0;
		current = null;
		next = null;
	}
}
